package com.cn.demo4.controller.index;

import com.alibaba.fastjson.JSONObject;
import com.cn.demo4.common.Tool;
import com.cn.demo4.entity.*;
import com.cn.demo4.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@Controller
public class CallUsController {
        @Autowired
        ICompanyService iCompanyService;
        @Autowired
        INewsTypeService iNewsTypeService;
        @Autowired
        INavService iNavService;
        @Autowired
        INewsService iNewsService;
        @Autowired
        IConsultingService iConsultingService;
        @Autowired
        IOnlineService iOnlineService;
        @Autowired
        IHrService iHrService;
        @Autowired
        ILayoutService iLayoutService;
        @Autowired
        IProductService iProductService;

        @RequestMapping("/callUs")
        @ResponseBody
        public void callUsController(HttpServletResponse resp, HttpServletRequest req) throws IOException {
            Tool.setEncoding(req, resp);
            CompanyEntity companyModel = iCompanyService.getCompanyModelForHome();
            List<ConsultingEntity> consultingModelList = iConsultingService.getConsultingModelListForHome();
            List<NavEntity> navModelList = iNavService.getNavModelListForHome();
            List<OnlineEntity> onlineModelList = iOnlineService.getOnlineModelListForHome();
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("companyModel",companyModel);
            jsonObject.put("navModelList",navModelList);
            jsonObject.put("consultingModelList",consultingModelList);
            jsonObject.put("onlineModelList",onlineModelList);
            resp.getWriter().println(jsonObject);
        }
}
